const log4js = require('log4js'),
        path = require('path')
 
log4js.configure({
    replaceConsole: true,
    appenders: {
        info: {
            type: 'dateFile',
            filename: './log/info/',
            pattern: 'yyyy-MM-dd.log',
            alwaysIncludePattern: true
        },
    },
    categories: {
        default: { appenders: ['info'], level: 'info' },
    }
})
 
exports.getLogger = function (name) {//name取categories项
    return log4js.getLogger(name || 'info')
}
 
exports.useLogger = function (app, logger) {//用来与express结合
    app.use(log4js.connectLogger(logger || log4js.getLogger('info'), {
        format: '[:remote-addr :method :url :status :response-timems][:referrer HTTP/:http-version :user-agent]'//自定义输出格式
    }))
}